package com.gxa.web_admin.controller.accesscontroller;

import com.gxa.common.R;
import com.gxa.modules.service.accessservice.LoginService;
import io.swagger.annotations.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

/**
 * 登录
 * @author 86156
 */

@RestController
@Api(value = "登录模块",tags = "登录API")
public class LoginController {

    @Autowired
    private LoginService loginService;

    /**
     * 登录接口
     * @return 返回登录成功
     */
    @RequestMapping(value = "login",method = RequestMethod.POST)
    @ApiOperation(value = "登录接口",notes = "登录",httpMethod = "POST", response = String.class)
    @ApiImplicitParams({
            @ApiImplicitParam(name = "loginName",value = "登录名称",paramType = "query",dataType = "String",required = true),
            @ApiImplicitParam(name = "password",value = "密码",paramType = "query",dataType = "String",required = true)
    })
    @ApiResponses({
            @ApiResponse(code=200,message="请求成功"),
            @ApiResponse(code=404,message="找不到页面"),
            @ApiResponse(code=500,message="后台服务错误")
    })
    public R login(String loginName, String password){
        return loginService.login(loginName,password);
    }

    /**
     * 退出登录
     * @return 返回成功
     */
    @RequestMapping(value = "loginOut",method = RequestMethod.POST)
    @ApiOperation(value = "退出登录接口",notes = "退出登录",httpMethod = "POST", response = String.class)
    @ApiImplicitParam(name = "loginName",value = "登录名称",paramType = "query",dataType = "String",required = true)
    @ApiResponses({
            @ApiResponse(code=200,message="请求成功"),
            @ApiResponse(code=404,message="找不到页面"),
            @ApiResponse(code=500,message="后台服务错误")
    })
    public R loginOut(String loginName){
        return loginService.loginOut(loginName);
    }
}
